import axios from 'axios';

const baseURL = 'http://localhost:5173';

const instance = axios.create({baseURL});

instance.interceptors.response.use(
    result => {
        if(result.data.code == 200){
            console.log("get data success");
            return result.data.result;
        }else{
            console.log("get data fail"+result.data.code);
            return Promise.reject(result.data);
        }
            
    },
    err =>{
        alert("服务异常。。。");
        return Promise.reject(err);  //异步的状态转化为失败的状态
    }
)

export default instance;